//#include "IVObject.h"
//
//using namespace std;
//
//SoSeparator *ReadScene(const char *filename)
//{
//	SoSeparator *root;
//	SoInput in;
//
//	if (!in.openFile(filename)) 
//	{
//		cerr << "Error opening file " << filename << endl;
//		exit(1);
//	}
//
//	root = SoDB::readAll(&in);
//
//	if (root == NULL)
//		cerr << "Error reading file " << filename << endl;
//	else
//		root->ref();
//	
//	in.closeFile();
//	return root;
//}
//
//static SoCallbackAction::Response processNodesCB(void *userData, SoCallbackAction *ca, const SoNode *node)
//{
//	if (node->isOfType(SoShape::getClassTypeId())) 
//	{
//		SbPList *data_list = (SbPList*) userData;
//		IVObject *data = new IVObject;
//		data_list->append((void *) data);
//		data->objShape = node->copy();
//		data->objShape->ref();
//		SoVertexShape* vertShape = (SoVertexShape *)data->objShape;
//
//		SoState* state = ca->getState();
//		SoLazyElement* le = SoLazyElement::getInstance(state);
//
//		int sIndex = 0;
//		if (node->isOfType(SoVertexShape::getClassTypeId())) 
//		{
//			const SoCoordinateElement* ce;
//			ce = SoCoordinateElement::getInstance(state);
//
//			if (vertShape->isOfType(SoNonIndexedShape::getClassTypeId()))
//			{
//				sIndex = ((SoNonIndexedShape*)vertShape)->startIndex.getValue();
//				((SoNonIndexedShape*)vertShape)->startIndex.setValue(0);
//			}
//
//			if (ce->is3D())
//			{   // It's 3D
//                SoCoordinate3 *Ps = new SoCoordinate3;
//				Ps->point.setValues(0, ce->getNum() - sIndex,&ce->get3(sIndex));
//				Ps->ref();
//				data->points = (SoNode *) Ps;
//			}
//
//			const SoNormalElement* ne = SoNormalElement::getInstance(state);
//
//			SoNormalBinding::Binding nb = (SoNormalBinding::Binding)SoNormalBindingElement::get(state);
//			
//			int startNrmIndex = 0;
//			if (ne != NULL && ne->getNum()>0)
//			{
//				// vp->normalBinding.setValue(nb);
//				if (nb == SoNormalBinding::PER_VERTEX){
//					startNrmIndex = sIndex;
//				}
//				data->normals = new SoNormal;
//				data->normals->ref();
//				data->normals->vector.setValues(0, (ne->getNum())-startNrmIndex, &ne->get(startNrmIndex));    
//			}
//		}
//		
//		SbMatrix const xm = ca->getModelMatrix();
//		data->transformation = new SoTransform;
//		data->transformation->ref();
//		data->transformation->setMatrix(xm);
//
//		data->units = new SoUnits;
//		data->units->ref();
//		data->units->units = ca->getUnits();
//
//		data->shapeHints = new SoShapeHints;
//		data->shapeHints->ref();
//		data->shapeHints->shapeType = ca->getShapeType();
//		data->shapeHints->faceType = ca->getFaceType();
//		data->shapeHints->vertexOrdering = ca->getVertexOrdering();
//
//        //data->shapeHints->vertexOrdering.getValue();
//
//		SoMaterial *material = new SoMaterial;
//		material->ref();
//		material->ambientColor = SoLazyElement::getAmbient(state);
//		material->diffuseColor = SoLazyElement::getDiffuse(state, 0);
//		material->specularColor = SoLazyElement::getSpecular(state);
//		material->emissiveColor = SoLazyElement::getEmissive(state);
//		material->shininess = SoLazyElement::getShininess(state);
//		material->transparency = SoLazyElement::getTransparency(state, 0);
//		data->material = material;
//	}
//	return SoCallbackAction::CONTINUE;
//}
//
//IVObject::IVObject() 
//{
//	objShape = NULL;                         
//	points = NULL;   
//	normals = NULL;
//	material = NULL;
//	transformation = NULL;
//	shapeHints = NULL;
//	units = NULL;
//}
//
//IVObject::~IVObject() 
//{
//	if (points)
//		points->unref();
//	if (objShape)
//		objShape->unref();
//	if (normals)
//		normals->unref();
//	if (material)
//		material->unref();
//	if (transformation)
//		transformation->unref();
//	if (shapeHints)
//		shapeHints->unref();
//	if (units)
//		units->unref();
//}
//
//bool IVObject::Check() const
//{
//	if (objShape == NULL)
//		return false;
//	if (points == NULL)
//		return false;
//	if (normals == NULL)
//		return false;
//	if (material == NULL)
//		return false;
//	if (transformation == NULL)
//		return false;
//	if (shapeHints == NULL)
//		return false;
//	if (units == NULL)
//		return false;
//	return true;
//}
//
//IVScene::IVScene(const char *filename) 
//{
//	SoSeparator *root = ReadScene(filename);
//	SoCallbackAction ca;
//
//	ca.addPreCallback(SoNode::getClassTypeId(), processNodesCB, (void*)&objects);
//	ca.apply(root);
//}
